package com.ibm.spatiotemp.server.datasources;

import org.apache.log4j.Logger;

import com.ibm.spatiotemp.server.constants.Constant;
import com.ibm.spatiotemp.server.datasources.fake.FakeRawDataAccessor;
import com.ibm.spatiotemp.server.datasources.ifx.InformixRawDataAccessor;
import com.ibm.spatiotemp.server.datasources.mockdb.MockdbRawDataAccessor;
import com.ibm.spatiotemp.server.datasources.mysql.MysqlRawDataAccessor;

public class RawDataAccessorFactory {
	public static Logger logger = Logger.getLogger(RawDataAccessorFactory.class);
	
	public static RawDataAccessor getDataAccessorInstanceByDataSource(DataSource dsrc)
	{
		if(Constant.DB_CLASS_IFX.equalsIgnoreCase(dsrc.getSource_class()))
		{
			logger.info("create data accessor " + Constant.DB_CLASS_IFX);
			return new InformixRawDataAccessor(dsrc);
		}
		else if(Constant.DB_CLASS_MYSQL.equalsIgnoreCase(dsrc.getSource_class()))
			{
			logger.info("create data accessor " + Constant.DB_CLASS_MYSQL);
				return new MysqlRawDataAccessor(dsrc);
			}
		else if(Constant.DB_CLASS_MOCK.equalsIgnoreCase(dsrc.getSource_class()))
		{
			logger.info("create data accessor " + Constant.DB_CLASS_MOCK);
			return new MockdbRawDataAccessor(dsrc);
		}
		else if(Constant.DB_CLASS_FAKE.equalsIgnoreCase(dsrc.getSource_class()))
		{
			logger.info("create data accessor " + Constant.DB_CLASS_FAKE);
			return new FakeRawDataAccessor(dsrc);
		}
		return null;
		
	}
	
}
